# HHeretic Makefile
# $Revision: 507 $
#
# svga			build Software (SVGALib) version
# sdl			build Software (SDL) version
# opengl		build OpenGL (SDL) version
# clean:		remove all intermediate files
#
# It is ESSENTIAL that you run make clean between different
# types of builds or different types of targets.
#

# Basic stuff
SHELL = /bin/sh
VPATH = @srcdir@

top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = $(exec_prefix)/bin
infodir = $(prefix)/info
libdir = $(prefix)/lib
mandir = $(prefix)/man/man1
includedir = $(prefix)/include

CC = @CC@
DEFS = @DEFS@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
BASELIBS = @LIBS@
THREAD_LIBS = @THREAD_LIBS@
X11_INC = @X11_INC@
X11_LIB = @X11_LIB@
GLLIBS = @GLLIBS@
SVGALIBS = @SVGALIBS@
SDL_LIBS = @SDL_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@
GLHEXEN = @GLHEXEN@
SVGAHEXEN = @SVGAHEXEN@
SHARED_DATAPATH = @SHARED_DATAPATH@
SND_MODULE= @SND_MODULE@

# Directories

TOPSRCDIR = @top_srcdir@
TOPOBJDIR = .
SRCDIR    = @srcdir@
VPATH     = @srcdir@
MODULE    = none

INCSUBDIR = ./include

CPPFLAGS += -I$(INCSUBDIR)
ifneq ($(SVGAHEXEN),true)
ifneq ($(X11_INC),)
CPPFLAGS += -I$(X11_INC)
endif
CPPFLAGS += $(SDL_CFLAGS)
endif

ifneq ($(X11_LIB),)
GLLIBS := -L$(X11_LIB) $(GLLIBS)
endif

# Objects to build

OBJ_SYS  = unix/i_linux.o
OBJ_SVGA = svgalib/i_svgalib.o
OBJ_SWSDL = sdl/i_sdl.o
OBJ_GLSDL = sdl/i_sdlgl.o
OBJ_OSS = unix/oss.o unix/i_soundpi.o
OBJ_SDLAUDIO = sdl/i_sndsdl.o
OBJ_SDLMIXER = base/mmus2mid.o sdl/i_sdlmixer.o

ifeq ($(SND_MODULE),oss)
OBJ_SND:= $(OBJ_OSS)
BASELIBS:=$(BASELIBS) $(THREAD_LIBS)
endif
ifeq ($(SND_MODULE),sdl)
OBJ_SND:= $(OBJ_SDLAUDIO)
endif
ifeq ($(SND_MODULE),sdlmixer)
OBJ_SND:= $(OBJ_SDLMIXER)
endif

OBJ_OPENGL = \
	opengl/ogl_clip.o \
	opengl/ogl_draw.o \
	opengl/ogl_rend.o \
	opengl/ogl_rl.o \
	opengl/ogl_scr.o \
	opengl/ogl_sky.o \
	opengl/ogl_tex.o \
	opengl/ogl_main.o \
	opengl/m_bams.o

OBJ_BASE = \
	base/am_map.o \
	base/ct_chat.o \
	base/d_net.o \
	base/f_finale.o \
	base/g_game.o \
	base/d_main.o \
	base/info.o \
	base/in_lude.o \
	base/mn_menu.o \
	base/m_misc.o \
	base/p_ceilng.o \
	base/p_doors.o \
	base/p_enemy.o \
	base/p_floor.o \
	base/p_inter.o \
	base/p_lights.o \
	base/p_map.o \
	base/p_maputl.o \
	base/p_mobj.o \
	base/p_plats.o \
	base/p_pspr.o \
	base/p_setup.o \
	base/p_sight.o \
	base/p_spec.o \
	base/p_switch.o \
	base/p_telept.o \
	base/p_tick.o \
	base/p_user.o \
	base/r_bsp.o \
	base/r_data.o \
	base/r_draw.o \
	base/r_main.o \
	base/r_plane.o \
	base/r_segs.o \
	base/r_things.o \
	base/sb_bar.o \
	base/s_sound.o \
	base/sv_save.o \
	base/tables.o \
	base/v_video.o \
	base/w_wad.o \
	base/z_zone.o

%.o: %.c
	$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<


ifeq ($(SVGAHEXEN),true)
svga: $(OBJ_SYS) $(OBJ_SND) $(OBJ_SVGA) $(OBJ_BASE)
	$(CC) $(LDFLAGS) $(OBJ_SYS) $(OBJ_SND) $(OBJ_SVGA) $(OBJ_BASE) -o hheretic-svga $(BASELIBS) $(SVGALIBS)
else

ifeq ($(GLHEXEN),true)
opengl: $(OBJ_SYS) $(OBJ_SND) $(OBJ_GLSDL) $(OBJ_OPENGL) $(OBJ_BASE)
	$(CC) $(LDFLAGS) $(OBJ_SYS) $(OBJ_SND) $(OBJ_GLSDL) $(OBJ_OPENGL) $(OBJ_BASE) -o hheretic-gl $(BASELIBS) $(GLLIBS) $(SDL_LIBS)
else
sdl: $(OBJ_SYS) $(OBJ_SND) $(OBJ_SWSDL) $(OBJ_BASE)
	$(CC) $(LDFLAGS) $(OBJ_SYS) $(OBJ_SND) $(OBJ_SWSDL) $(OBJ_BASE) -o hheretic-sdl $(BASELIBS) $(SDL_LIBS)
endif

endif

clean:
	$(RM) base/*.o opengl/*.o dos/*.o unix/*.o sdl/*.o svgalib/*.o

